From 2a46b1b066a22ef93ba395f0ebf437f8e5e6351d Mon Sep 17 00:00:00 2001 From: "kfraser@localhost.localdomain" Date: Mon, 23 Oct 2006 09:57:24 +0100 Subject: [PATCH] [ACM] Don't use uninitialised struct value if hypercall fails. From: Jan Beulich Signed-off-by: Keir Fraser --- tools/python/xen/lowlevel/acm/acm.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tools/python/xen/lowlevel/acm/acm.c b/tools/python/xen/lowlevel/acm/acm.c index ec39b60bb4..930c568212 100644 --- a/tools/python/xen/lowlevel/acm/acm.c +++ b/tools/python/xen/lowlevel/acm/acm.c @@ -147,9 +147,10 @@ static PyObject *getdecision(PyObject * self, PyObject * args) { char *arg1_name, *arg1, *arg2_name, *arg2, *decision = NULL; struct acm_getdecision getdecision; - int xc_handle; + int xc_handle, rc; - if (!PyArg_ParseTuple(args, "ssss", &arg1_name, &arg1, &arg2_name, &arg2)) { + if (!PyArg_ParseTuple(args, "ssss", &arg1_name, + &arg1, &arg2_name, &arg2)) { return NULL; } @@ -179,13 +180,17 @@ static PyObject *getdecision(PyObject * self, PyObject * args) getdecision.id2.ssidref = atol(arg2); } - if (xc_acm_op(xc_handle, ACMOP_getdecision, &getdecision, sizeof(getdecision)) < 0) { + rc = xc_acm_op(xc_handle, ACMOP_getdecision, + &getdecision, sizeof(getdecision)); + + xc_interface_close(xc_handle); + + if (rc < 0) { if (errno == EACCES) PERROR("ACM operation failed."); + return NULL; } - xc_interface_close(xc_handle); - if (getdecision.acm_decision == ACM_ACCESS_PERMITTED) decision = "PERMITTED"; else if (getdecision.acm_decision == ACM_ACCESS_DENIED) -- 2.30.2